package com.example.springstudyvue.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.springstudyvue.entity.News;
import com.example.springstudyvue.mapper.NewsMapper;
import com.example.springstudyvue.service.NewsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author linKe
 * @since 2021-11-26
 */
@Service
public class NewsServiceImpl extends ServiceImpl<NewsMapper, News> implements NewsService {
    @Resource
    private NewsMapper newsMapper;

    @Override
    public Boolean addNews(News news) {
        news.setTime(new Date());
        return newsMapper.insert(news) > 0;
    }

    @Override
    public Boolean updateNews(News news) {
        return newsMapper.updateById(news) > 0;
    }

    @Override
    public boolean deleteNews(Long newsId) {
        return newsMapper.deleteById(newsId) > 0;
    }



}
